package com.plc.s7;

import com.github.s7connector.api.S7Connector;

public class test {

    public static S7Connector initConnect() {
        S7Client s7ConnectorPLC = new S7Client();
        S7Connector connector = s7ConnectorPLC.initConnect("172.16.3.218");//plc地址

        return connector;
    }

    public static void main(String[] args) {
        ReadPLC readPLC = new ReadPLC();//创建读取plc数据对象
        while (true) {
            S7Connector connector = initConnect();//初始化
            readPLC.Cyclic_read(connector,1001);//读取
            System.out.println("=============读取plc信息==============");
            System.out.println(readPLC.equipmentNo);
            System.out.println(readPLC.equipmentType);
            System.out.println(readPLC.state);
            System.out.println(readPLC.errorMessage);
            System.out.println("=============读取plc信息==============");
            try {
                Thread.sleep(1000);//stop 0.5s
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
//        for(int  i = 0;i<200;i++){
//
//            System.out.print(1);
//        };
//        String s ="11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111";
//        System.out.println(s.length());


    }
}
